library(parallel)
library(tictoc)

context("sampler eyeData")

vector_to_str <- function(vec)
{
	options(digits=16)
	cat("c(")
	for (i in 1:length(vec)) {
	  cat(vec[i])	
	  if (i < length(vec)) {
	  	  cat(",\n")
	  }
	}
	cat(")\n")
}

cores <- detectCores()
#cores <- 1
test_that('eyeData produces correct results BIC', {
	set.seed(2019)
	eyeData <- get_eyeData()
    vy <- eyeData$vy
    mX <- eyeData$mX
    p <- ncol(mX)
    tic('eyeData produces correct results BIC')
    result <- sampler(100000, vy, mX, prior='BIC', modelprior='beta-binomial', modelpriorvec=c(1, p), cores=cores)
    toc()
    expect_equal(result$vinclusion_prob, 
c(
0.003070000000000000,0.004640000000000000,0.001520000000000000,
0.001620000000000000,0.002320000000000000,0.003190000000000000,
0.001350000000000000,0.003650000000000000,0.001550000000000000,
0.002110000000000000,0.052030000000000000,0.002930000000000000,
0.002670000000000000,0.001800000000000000,0.001480000000000000,
0.003370000000000000,0.001370000000000000,0.001460000000000000,
0.002550000000000000,0.001300000000000000,0.001390000000000000,
0.001750000000000000,0.001910000000000000,0.001330000000000000,
0.001190000000000000,0.003670000000000000,0.001390000000000000,
0.011089999999999999,0.001110000000000000,0.003510000000000000,
0.004030000000000000,0.001300000000000000,0.002240000000000000,
0.001780000000000000,0.001570000000000000,0.005390000000000000,
0.001510000000000000,0.002090000000000000,0.001580000000000000,
0.001350000000000000,0.001530000000000000,0.035369999999999999,
0.001650000000000000,0.001530000000000000,0.001190000000000000,
0.001770000000000000,0.001490000000000000,0.001460000000000000,
0.002200000000000000,0.005640000000000000,0.001690000000000000,
0.002900000000000000,0.001450000000000000,0.009370000000000000,
0.010200000000000001,0.001230000000000000,0.001600000000000000,
0.001890000000000000,0.002760000000000000,0.008000000000000000,
0.001360000000000000,0.027779999999999999,0.002120000000000000,
0.001990000000000000,0.001860000000000000,0.008210000000000000,
0.001630000000000000,0.001590000000000000,0.001250000000000000,
0.001920000000000000,0.016410000000000001,0.001450000000000000,
0.001560000000000000,0.001710000000000000,0.001530000000000000,
0.022780000000000002,0.001650000000000000,0.002820000000000000,
0.001260000000000000,0.001760000000000000,0.001330000000000000,
0.001350000000000000,0.001620000000000000,0.001670000000000000,
0.003870000000000000,0.001860000000000000,0.177290000000000003,
0.001750000000000000,0.002050000000000000,0.020020000000000000,
0.001420000000000000,0.004860000000000000,0.002670000000000000,
0.001230000000000000,0.001560000000000000,0.004000000000000000,
0.001730000000000000,0.001280000000000000,0.010890000000000000,
0.002010000000000000,0.002140000000000000,0.007790000000000000,
0.001160000000000000,0.002980000000000000,0.001450000000000000,
0.001690000000000000,0.002850000000000000,0.003450000000000000,
0.021030000000000000,0.009200000000000000,0.003770000000000000,
0.013280000000000000,0.003660000000000000,0.001690000000000000,
0.001650000000000000,0.001480000000000000,0.003150000000000000,
0.001300000000000000,0.001560000000000000,0.001550000000000000,
0.001640000000000000,0.001350000000000000,0.007310000000000000,
0.002680000000000000,0.007050000000000000,0.001420000000000000,
0.008590000000000000,0.001570000000000000,0.001670000000000000,
0.001500000000000000,0.001560000000000000,0.007280000000000000,
0.001310000000000000,0.007270000000000000,0.004490000000000000,
0.022100000000000002,0.002480000000000000,0.001380000000000000,
0.001700000000000000,0.009050000000000001,0.010170000000000000,
0.001450000000000000,0.001530000000000000,0.001330000000000000,
0.001650000000000000,0.006460000000000000,0.007220000000000000,
0.002790000000000000,0.001270000000000000,0.001380000000000000,
0.002520000000000000,0.002020000000000000,0.962860000000000049,
0.005430000000000000,0.026089999999999999,0.001590000000000000,
0.006490000000000000,0.006180000000000000,0.011100000000000000,
0.001640000000000000,0.004920000000000000,0.005640000000000000,
0.002970000000000000,0.017309999999999999,0.001920000000000000,
0.001920000000000000,0.001220000000000000,0.002040000000000000,
0.001240000000000000,0.003300000000000000,0.001500000000000000,
0.021860000000000001,0.003580000000000000,0.001980000000000000,
0.003310000000000000,0.002330000000000000,0.006820000000000000,
0.001410000000000000,0.002230000000000000,0.808849999999999958,
0.057380000000000000,0.018759999999999999,0.006180000000000000,
0.004210000000000000,0.791989999999999972,0.001840000000000000,
0.041329999999999999,0.008900000000000000,0.003100000000000000,
0.002810000000000000,0.001650000000000000,0.001420000000000000,
0.001300000000000000,0.001350000000000000,0.001290000000000000,
0.003110000000000000,0.001560000000000000,0.002200000000000000,
0.003520000000000000,0.055120000000000002
)
, tolerance = 1e-8)
})
test_that('eyeData produces correct results ZE', {
	set.seed(2019)
	eyeData <- get_eyeData()
    vy <- eyeData$vy
    mX <- eyeData$mX
    p <- ncol(mX)
    tic('eyeData produces correct results ZE')
    result <- sampler(100000, vy, mX, prior='ZE', modelprior='beta-binomial', modelpriorvec=c(1, p), cores=cores)
    toc()
    expect_equal(result$vinclusion_prob, 
c(
0.003210000000000000,0.004930000000000000,0.001490000000000000,
0.001730000000000000,0.002620000000000000,0.003470000000000000,
0.001390000000000000,0.003670000000000000,0.001770000000000000,
0.002050000000000000,0.057650000000000000,0.003180000000000000,
0.002730000000000000,0.001890000000000000,0.001510000000000000,
0.003110000000000000,0.001390000000000000,0.001630000000000000,
0.002450000000000000,0.001310000000000000,0.001460000000000000,
0.001700000000000000,0.001970000000000000,0.001420000000000000,
0.001400000000000000,0.003430000000000000,0.001530000000000000,
0.009630000000000000,0.001270000000000000,0.003470000000000000,
0.004070000000000000,0.001350000000000000,0.002560000000000000,
0.001750000000000000,0.001690000000000000,0.005790000000000000,
0.001460000000000000,0.002430000000000000,0.001550000000000000,
0.001560000000000000,0.001530000000000000,0.039820000000000001,
0.001680000000000000,0.001570000000000000,0.001370000000000000,
0.001890000000000000,0.001550000000000000,0.001460000000000000,
0.002270000000000000,0.005690000000000000,0.001610000000000000,
0.003560000000000000,0.001570000000000000,0.009960000000000000,
0.009299999999999999,0.001200000000000000,0.001720000000000000,
0.002090000000000000,0.002510000000000000,0.010019999999999999,
0.001300000000000000,0.027560000000000001,0.002050000000000000,
0.002320000000000000,0.001990000000000000,0.007060000000000000,
0.001700000000000000,0.001570000000000000,0.001360000000000000,
0.001940000000000000,0.013469999999999999,0.001460000000000000,
0.001570000000000000,0.001960000000000000,0.001630000000000000,
0.017649999999999999,0.001700000000000000,0.002720000000000000,
0.001350000000000000,0.001780000000000000,0.001430000000000000,
0.001440000000000000,0.001590000000000000,0.001690000000000000,
0.004440000000000000,0.001740000000000000,0.170880000000000004,
0.001950000000000000,0.002240000000000000,0.021110000000000000,
0.001350000000000000,0.005040000000000000,0.002750000000000000,
0.001190000000000000,0.001650000000000000,0.004250000000000000,
0.001820000000000000,0.001380000000000000,0.013420000000000000,
0.001940000000000000,0.002220000000000000,0.009050000000000001,
0.001250000000000000,0.003260000000000000,0.001550000000000000,
0.001760000000000000,0.003250000000000000,0.003580000000000000,
0.023279999999999999,0.008170000000000000,0.003900000000000000,
0.015250000000000000,0.003810000000000000,0.001770000000000000,
0.001710000000000000,0.001420000000000000,0.003510000000000000,
0.001400000000000000,0.001550000000000000,0.001540000000000000,
0.001670000000000000,0.001280000000000000,0.006630000000000000,
0.002760000000000000,0.007750000000000000,0.001440000000000000,
0.009719999999999999,0.001560000000000000,0.001630000000000000,
0.001560000000000000,0.001680000000000000,0.008399999999999999,
0.001350000000000000,0.007770000000000000,0.004560000000000000,
0.024140000000000002,0.002420000000000000,0.001510000000000000,
0.001750000000000000,0.009800000000000000,0.010659999999999999,
0.001510000000000000,0.001840000000000000,0.001390000000000000,
0.001630000000000000,0.006990000000000000,0.007930000000000000,
0.003400000000000000,0.001370000000000000,0.001530000000000000,
0.002740000000000000,0.002450000000000000,0.951949999999999963,
0.005460000000000000,0.031899999999999998,0.001590000000000000,
0.008279999999999999,0.007700000000000000,0.014449999999999999,
0.002070000000000000,0.005440000000000000,0.005910000000000000,
0.002640000000000000,0.015810000000000001,0.002140000000000000,
0.001950000000000000,0.001290000000000000,0.002270000000000000,
0.001280000000000000,0.003580000000000000,0.001610000000000000,
0.024559999999999998,0.003650000000000000,0.002000000000000000,
0.003360000000000000,0.002270000000000000,0.006390000000000000,
0.001370000000000000,0.002250000000000000,0.761009999999999964,
0.057459999999999997,0.018050000000000000,0.007110000000000000,
0.004210000000000000,0.746240000000000014,0.001880000000000000,
0.043420000000000000,0.009540000000000000,0.003280000000000000,
0.003130000000000000,0.001720000000000000,0.001510000000000000,
0.001280000000000000,0.001540000000000000,0.001300000000000000,
0.003590000000000000,0.001710000000000000,0.002270000000000000,
0.003790000000000000,0.052310000000000002
)
, tolerance = 1e-8)
})
test_that('eyeData produces correct results liang_g1', {
	set.seed(2019)
	eyeData <- get_eyeData()
    vy <- eyeData$vy
    mX <- eyeData$mX
    p <- ncol(mX)
    tic('eyeData produces correct results liang_g1')
    result <- sampler(100000, vy, mX, prior='liang_g1', modelprior='beta-binomial', modelpriorvec=c(1, p), cores=cores)
    toc()
    expect_equal(result$vinclusion_prob, 
c(
0.004290000000000000,0.006320000000000000,0.002080000000000000,
0.002330000000000000,0.003490000000000000,0.004490000000000000,
0.002020000000000000,0.004680000000000000,0.002330000000000000,
0.002650000000000000,0.063049999999999995,0.003870000000000000,
0.003610000000000000,0.002280000000000000,0.002030000000000000,
0.003880000000000000,0.001820000000000000,0.002030000000000000,
0.003440000000000000,0.001780000000000000,0.001980000000000000,
0.002200000000000000,0.002500000000000000,0.001860000000000000,
0.001810000000000000,0.004470000000000000,0.001990000000000000,
0.011979999999999999,0.001800000000000000,0.004710000000000000,
0.005240000000000000,0.001840000000000000,0.003270000000000000,
0.002290000000000000,0.002170000000000000,0.007300000000000000,
0.002080000000000000,0.003110000000000000,0.002110000000000000,
0.002000000000000000,0.002090000000000000,0.041799999999999997,
0.002240000000000000,0.002130000000000000,0.001790000000000000,
0.002530000000000000,0.002030000000000000,0.002100000000000000,
0.002930000000000000,0.008290000000000000,0.002420000000000000,
0.004300000000000000,0.002020000000000000,0.013559999999999999,
0.011639999999999999,0.001590000000000000,0.002270000000000000,
0.002750000000000000,0.003400000000000000,0.011590000000000000,
0.001990000000000000,0.034369999999999998,0.002920000000000000,
0.002860000000000000,0.002710000000000000,0.009639999999999999,
0.002300000000000000,0.002120000000000000,0.001990000000000000,
0.002620000000000000,0.017639999999999999,0.001960000000000000,
0.002110000000000000,0.002650000000000000,0.002170000000000000,
0.023130000000000001,0.002390000000000000,0.003600000000000000,
0.001770000000000000,0.002360000000000000,0.001840000000000000,
0.001930000000000000,0.002170000000000000,0.002380000000000000,
0.005350000000000000,0.002410000000000000,0.189319999999999988,
0.002410000000000000,0.003110000000000000,0.025520000000000001,
0.001790000000000000,0.006450000000000000,0.003520000000000000,
0.001750000000000000,0.002070000000000000,0.005220000000000000,
0.002200000000000000,0.001750000000000000,0.015490000000000000,
0.002540000000000000,0.002940000000000000,0.011870000000000000,
0.001620000000000000,0.003990000000000000,0.002030000000000000,
0.002380000000000000,0.004450000000000000,0.004980000000000000,
0.024299999999999999,0.010279999999999999,0.004890000000000000,
0.017850000000000001,0.004900000000000000,0.002460000000000000,
0.002130000000000000,0.002020000000000000,0.004060000000000000,
0.001810000000000000,0.002040000000000000,0.001990000000000000,
0.002120000000000000,0.001880000000000000,0.008350000000000000,
0.003550000000000000,0.009230000000000000,0.002020000000000000,
0.011809999999999999,0.002150000000000000,0.002220000000000000,
0.002170000000000000,0.002220000000000000,0.009259999999999999,
0.001850000000000000,0.010059999999999999,0.005620000000000000,
0.027380000000000002,0.003020000000000000,0.001830000000000000,
0.002220000000000000,0.013200000000000000,0.013129999999999999,
0.001930000000000000,0.002330000000000000,0.001780000000000000,
0.002180000000000000,0.009169999999999999,0.009410000000000000,
0.004050000000000000,0.001680000000000000,0.001930000000000000,
0.003390000000000000,0.003050000000000000,0.943869999999999987,
0.006420000000000000,0.033320000000000002,0.002280000000000000,
0.010140000000000000,0.009160000000000000,0.016150000000000001,
0.002620000000000000,0.006920000000000000,0.007080000000000000,
0.003550000000000000,0.018900000000000000,0.002580000000000000,
0.002410000000000000,0.001750000000000000,0.002970000000000000,
0.001730000000000000,0.004590000000000000,0.002100000000000000,
0.027510000000000000,0.004630000000000000,0.002920000000000000,
0.004540000000000000,0.003110000000000000,0.007810000000000000,
0.001830000000000000,0.003050000000000000,0.744199999999999973,
0.061870000000000001,0.021120000000000000,0.008080000000000000,
0.005510000000000000,0.723239999999999994,0.002420000000000000,
0.049439999999999998,0.012470000000000000,0.004250000000000000,
0.004070000000000000,0.002160000000000000,0.001960000000000000,
0.001750000000000000,0.002040000000000000,0.001680000000000000,
0.005090000000000000,0.002210000000000000,0.002810000000000000,
0.005320000000000000,0.060190000000000000
)
, tolerance = 1e-8)
})
test_that('eyeData produces correct results liang_g2', {
	set.seed(2019)
	eyeData <- get_eyeData()
    vy <- eyeData$vy
    mX <- eyeData$mX
    p <- ncol(mX)
    tic('eyeData produces correct results liang_g2')
    result <- sampler(100000, vy, mX, prior='liang_g2', modelprior='beta-binomial', modelpriorvec=c(1, p), cores=cores)
    toc()
    expect_equal(result$vinclusion_prob, 
c(
0.004290000000000000,0.006320000000000000,0.002080000000000000,
0.002330000000000000,0.003490000000000000,0.004490000000000000,
0.002020000000000000,0.004680000000000000,0.002330000000000000,
0.002650000000000000,0.063049999999999995,0.003870000000000000,
0.003610000000000000,0.002280000000000000,0.002030000000000000,
0.003880000000000000,0.001820000000000000,0.002030000000000000,
0.003440000000000000,0.001780000000000000,0.001980000000000000,
0.002200000000000000,0.002500000000000000,0.001860000000000000,
0.001810000000000000,0.004470000000000000,0.001990000000000000,
0.011979999999999999,0.001800000000000000,0.004710000000000000,
0.005240000000000000,0.001840000000000000,0.003270000000000000,
0.002290000000000000,0.002170000000000000,0.007300000000000000,
0.002080000000000000,0.003110000000000000,0.002110000000000000,
0.002000000000000000,0.002090000000000000,0.041799999999999997,
0.002240000000000000,0.002130000000000000,0.001790000000000000,
0.002530000000000000,0.002030000000000000,0.002100000000000000,
0.002930000000000000,0.008290000000000000,0.002420000000000000,
0.004300000000000000,0.002020000000000000,0.013559999999999999,
0.011639999999999999,0.001590000000000000,0.002270000000000000,
0.002750000000000000,0.003400000000000000,0.011590000000000000,
0.001990000000000000,0.034369999999999998,0.002920000000000000,
0.002860000000000000,0.002710000000000000,0.009639999999999999,
0.002300000000000000,0.002120000000000000,0.001990000000000000,
0.002620000000000000,0.017639999999999999,0.001960000000000000,
0.002110000000000000,0.002650000000000000,0.002170000000000000,
0.023130000000000001,0.002390000000000000,0.003600000000000000,
0.001770000000000000,0.002360000000000000,0.001840000000000000,
0.001930000000000000,0.002170000000000000,0.002380000000000000,
0.005350000000000000,0.002410000000000000,0.189319999999999988,
0.002410000000000000,0.003110000000000000,0.025520000000000001,
0.001790000000000000,0.006450000000000000,0.003520000000000000,
0.001750000000000000,0.002070000000000000,0.005220000000000000,
0.002200000000000000,0.001750000000000000,0.015490000000000000,
0.002540000000000000,0.002940000000000000,0.011870000000000000,
0.001620000000000000,0.003990000000000000,0.002030000000000000,
0.002380000000000000,0.004450000000000000,0.004980000000000000,
0.024299999999999999,0.010279999999999999,0.004890000000000000,
0.017850000000000001,0.004900000000000000,0.002460000000000000,
0.002130000000000000,0.002020000000000000,0.004060000000000000,
0.001810000000000000,0.002040000000000000,0.001990000000000000,
0.002120000000000000,0.001880000000000000,0.008350000000000000,
0.003550000000000000,0.009230000000000000,0.002020000000000000,
0.011809999999999999,0.002150000000000000,0.002220000000000000,
0.002170000000000000,0.002220000000000000,0.009259999999999999,
0.001850000000000000,0.010059999999999999,0.005620000000000000,
0.027380000000000002,0.003020000000000000,0.001830000000000000,
0.002220000000000000,0.013200000000000000,0.013129999999999999,
0.001930000000000000,0.002330000000000000,0.001780000000000000,
0.002180000000000000,0.009169999999999999,0.009410000000000000,
0.004050000000000000,0.001680000000000000,0.001930000000000000,
0.003390000000000000,0.003050000000000000,0.943869999999999987,
0.006420000000000000,0.033320000000000002,0.002280000000000000,
0.010140000000000000,0.009160000000000000,0.016150000000000001,
0.002620000000000000,0.006920000000000000,0.007080000000000000,
0.003550000000000000,0.018900000000000000,0.002580000000000000,
0.002410000000000000,0.001750000000000000,0.002970000000000000,
0.001730000000000000,0.004590000000000000,0.002100000000000000,
0.027510000000000000,0.004630000000000000,0.002920000000000000,
0.004540000000000000,0.003110000000000000,0.007810000000000000,
0.001830000000000000,0.003050000000000000,0.744199999999999973,
0.061870000000000001,0.021120000000000000,0.008080000000000000,
0.005510000000000000,0.723239999999999994,0.002420000000000000,
0.049439999999999998,0.012470000000000000,0.004250000000000000,
0.004070000000000000,0.002160000000000000,0.001960000000000000,
0.001750000000000000,0.002040000000000000,0.001680000000000000,
0.005090000000000000,0.002210000000000000,0.002810000000000000,
0.005320000000000000,0.060190000000000000
)
, tolerance = 1e-8)
})
test_that('eyeData produces correct results liang_g_n_approx', {
	set.seed(2019)
	eyeData <- get_eyeData()
    vy <- eyeData$vy
    mX <- eyeData$mX
    p <- ncol(mX)
    tic('eyeData produces correct results liang_g_n_approx')
    result <- sampler(100000, vy, mX, prior='liang_g_n_approx', modelprior='beta-binomial', modelpriorvec=c(1, p), cores=cores)
    toc()
    expect_equal(result$vinclusion_prob, 
c(
0.002960000000000000,0.004160000000000000,0.001310000000000000,
0.001590000000000000,0.002410000000000000,0.003000000000000000,
0.001210000000000000,0.003320000000000000,0.001470000000000000,
0.001790000000000000,0.052209999999999999,0.002880000000000000,
0.002450000000000000,0.001700000000000000,0.001260000000000000,
0.002790000000000000,0.001180000000000000,0.001370000000000000,
0.002160000000000000,0.001140000000000000,0.001270000000000000,
0.001370000000000000,0.001810000000000000,0.001300000000000000,
0.001210000000000000,0.003060000000000000,0.001410000000000000,
0.008619999999999999,0.001170000000000000,0.002900000000000000,
0.003710000000000000,0.001170000000000000,0.002280000000000000,
0.001510000000000000,0.001420000000000000,0.005520000000000000,
0.001330000000000000,0.002250000000000000,0.001370000000000000,
0.001290000000000000,0.001360000000000000,0.036740000000000002,
0.001400000000000000,0.001310000000000000,0.001200000000000000,
0.001600000000000000,0.001310000000000000,0.001250000000000000,
0.001990000000000000,0.004840000000000000,0.001440000000000000,
0.002950000000000000,0.001250000000000000,0.008910000000000000,
0.008370000000000001,0.001010000000000000,0.001500000000000000,
0.001810000000000000,0.002330000000000000,0.008619999999999999,
0.001200000000000000,0.024260000000000000,0.001850000000000000,
0.002020000000000000,0.001670000000000000,0.006400000000000000,
0.001560000000000000,0.001310000000000000,0.001100000000000000,
0.001610000000000000,0.012140000000000000,0.001340000000000000,
0.001530000000000000,0.001760000000000000,0.001390000000000000,
0.015869999999999999,0.001500000000000000,0.002360000000000000,
0.001190000000000000,0.001560000000000000,0.001270000000000000,
0.001320000000000000,0.001420000000000000,0.001600000000000000,
0.004030000000000000,0.001540000000000000,0.157810000000000006,
0.001710000000000000,0.001950000000000000,0.018720000000000001,
0.001180000000000000,0.004500000000000000,0.002380000000000000,
0.001110000000000000,0.001450000000000000,0.003660000000000000,
0.001540000000000000,0.001270000000000000,0.012489999999999999,
0.001820000000000000,0.001920000000000000,0.007860000000000001,
0.001050000000000000,0.002790000000000000,0.001400000000000000,
0.001570000000000000,0.003030000000000000,0.003260000000000000,
0.021319999999999999,0.007420000000000000,0.003390000000000000,
0.013760000000000000,0.003280000000000000,0.001420000000000000,
0.001450000000000000,0.001350000000000000,0.003040000000000000,
0.001100000000000000,0.001280000000000000,0.001410000000000000,
0.001540000000000000,0.001090000000000000,0.005930000000000000,
0.002510000000000000,0.006840000000000000,0.001280000000000000,
0.009070000000000000,0.001430000000000000,0.001430000000000000,
0.001410000000000000,0.001470000000000000,0.007570000000000000,
0.001120000000000000,0.006760000000000000,0.003880000000000000,
0.022270000000000002,0.002250000000000000,0.001360000000000000,
0.001550000000000000,0.008550000000000000,0.009560000000000001,
0.001230000000000000,0.001650000000000000,0.001280000000000000,
0.001400000000000000,0.005950000000000000,0.007030000000000000,
0.002900000000000000,0.001190000000000000,0.001260000000000000,
0.002390000000000000,0.002150000000000000,0.958139999999999992,
0.004770000000000000,0.027760000000000000,0.001470000000000000,
0.007140000000000000,0.007020000000000000,0.013169999999999999,
0.001630000000000000,0.004960000000000000,0.005630000000000000,
0.002340000000000000,0.014310000000000000,0.001910000000000000,
0.001630000000000000,0.001050000000000000,0.002020000000000000,
0.001150000000000000,0.003200000000000000,0.001350000000000000,
0.020930000000000001,0.003320000000000000,0.001720000000000000,
0.003150000000000000,0.002120000000000000,0.005870000000000000,
0.001230000000000000,0.002030000000000000,0.784760000000000013,
0.055120000000000002,0.016410000000000001,0.006210000000000000,
0.003860000000000000,0.765490000000000004,0.001490000000000000,
0.040500000000000001,0.008290000000000000,0.002840000000000000,
0.002650000000000000,0.001550000000000000,0.001300000000000000,
0.001130000000000000,0.001300000000000000,0.001240000000000000,
0.003050000000000000,0.001480000000000000,0.002020000000000000,
0.003400000000000000,0.047879999999999999
)
, tolerance = 1e-8)
})
test_that('eyeData produces correct results liang_g_n_quad', {
	set.seed(2019)
	eyeData <- get_eyeData()
    vy <- eyeData$vy
    mX <- eyeData$mX
    p <- ncol(mX)
    tic('eyeData produces correct results liang_g_n_quad')
    result <- sampler(100000, vy, mX, prior='liang_g_n_quad', modelprior='beta-binomial', modelpriorvec=c(1, p), cores=cores)
    toc()
    expect_equal(result$vinclusion_prob, 
c(
0.003250000000000000,0.005040000000000000,0.001490000000000000,
0.001730000000000000,0.002650000000000000,0.003510000000000000,
0.001410000000000000,0.003790000000000000,0.001790000000000000,
0.002090000000000000,0.058830000000000000,0.003240000000000000,
0.002910000000000000,0.001950000000000000,0.001560000000000000,
0.003160000000000000,0.001370000000000000,0.001640000000000000,
0.002520000000000000,0.001380000000000000,0.001550000000000000,
0.001720000000000000,0.002040000000000000,0.001430000000000000,
0.001420000000000000,0.003460000000000000,0.001570000000000000,
0.009760000000000000,0.001290000000000000,0.003570000000000000,
0.004240000000000000,0.001340000000000000,0.002590000000000000,
0.001790000000000000,0.001730000000000000,0.005940000000000000,
0.001480000000000000,0.002590000000000000,0.001640000000000000,
0.001550000000000000,0.001570000000000000,0.040349999999999997,
0.001750000000000000,0.001640000000000000,0.001380000000000000,
0.001950000000000000,0.001610000000000000,0.001550000000000000,
0.002350000000000000,0.005880000000000000,0.001660000000000000,
0.003730000000000000,0.001610000000000000,0.010380000000000000,
0.009490000000000000,0.001230000000000000,0.001850000000000000,
0.002170000000000000,0.002580000000000000,0.010200000000000001,
0.001400000000000000,0.028000000000000001,0.002120000000000000,
0.002330000000000000,0.002010000000000000,0.007410000000000000,
0.001750000000000000,0.001640000000000000,0.001380000000000000,
0.002000000000000000,0.013729999999999999,0.001470000000000000,
0.001590000000000000,0.002000000000000000,0.001670000000000000,
0.017960000000000000,0.001820000000000000,0.002800000000000000,
0.001470000000000000,0.001840000000000000,0.001460000000000000,
0.001460000000000000,0.001660000000000000,0.001710000000000000,
0.004440000000000000,0.001830000000000000,0.174080000000000013,
0.001960000000000000,0.002340000000000000,0.021350000000000001,
0.001370000000000000,0.005250000000000000,0.002810000000000000,
0.001230000000000000,0.001660000000000000,0.004330000000000000,
0.001850000000000000,0.001410000000000000,0.014090000000000000,
0.001980000000000000,0.002280000000000000,0.009290000000000000,
0.001260000000000000,0.003390000000000000,0.001540000000000000,
0.001780000000000000,0.003390000000000000,0.003730000000000000,
0.023640000000000001,0.008250000000000000,0.003920000000000000,
0.015210000000000000,0.003870000000000000,0.001930000000000000,
0.001810000000000000,0.001470000000000000,0.003480000000000000,
0.001440000000000000,0.001650000000000000,0.001560000000000000,
0.001720000000000000,0.001320000000000000,0.006700000000000000,
0.002820000000000000,0.007939999999999999,0.001500000000000000,
0.009800000000000000,0.001720000000000000,0.001640000000000000,
0.001560000000000000,0.001720000000000000,0.008529999999999999,
0.001370000000000000,0.008300000000000000,0.004600000000000000,
0.024539999999999999,0.002480000000000000,0.001500000000000000,
0.001830000000000000,0.010200000000000001,0.010950000000000000,
0.001550000000000000,0.001900000000000000,0.001420000000000000,
0.001690000000000000,0.007060000000000000,0.008109999999999999,
0.003540000000000000,0.001390000000000000,0.001560000000000000,
0.002860000000000000,0.002460000000000000,0.950130000000000030,
0.005550000000000000,0.033149999999999999,0.001570000000000000,
0.008550000000000000,0.007780000000000000,0.014040000000000000,
0.002160000000000000,0.005580000000000000,0.006210000000000000,
0.002660000000000000,0.016109999999999999,0.002190000000000000,
0.001980000000000000,0.001290000000000000,0.002260000000000000,
0.001330000000000000,0.003810000000000000,0.001640000000000000,
0.025040000000000000,0.003660000000000000,0.002130000000000000,
0.003500000000000000,0.002340000000000000,0.006620000000000000,
0.001360000000000000,0.002320000000000000,0.756449999999999956,
0.058259999999999999,0.017840000000000002,0.007320000000000000,
0.004340000000000000,0.742110000000000047,0.001890000000000000,
0.044319999999999998,0.009889999999999999,0.003400000000000000,
0.003170000000000000,0.001730000000000000,0.001550000000000000,
0.001340000000000000,0.001560000000000000,0.001340000000000000,
0.003910000000000000,0.001760000000000000,0.002360000000000000,
0.003800000000000000,0.053039999999999997
)
, tolerance = 1e-8)
})
test_that('eyeData produces correct results robust_bayarri1', {
	set.seed(2019)
	eyeData <- get_eyeData()
    vy <- eyeData$vy
    mX <- eyeData$mX
    p <- ncol(mX)
    tic('eyeData produces correct results robust_bayarri1')
    result <- sampler(100000, vy, mX, prior='robust_bayarri1', modelprior='beta-binomial', modelpriorvec=c(1, p), cores=cores)
    toc()
    expect_equal(result$vinclusion_prob, 
c(
0.003640000000000000,0.005560000000000000,0.001800000000000000,
0.002100000000000000,0.003090000000000000,0.004250000000000000,
0.001810000000000000,0.004290000000000000,0.001980000000000000,
0.002430000000000000,0.063289999999999999,0.003570000000000000,
0.003430000000000000,0.002090000000000000,0.001810000000000000,
0.003470000000000000,0.001580000000000000,0.001790000000000000,
0.003130000000000000,0.001620000000000000,0.001760000000000000,
0.001930000000000000,0.002170000000000000,0.001630000000000000,
0.001640000000000000,0.003900000000000000,0.001750000000000000,
0.010690000000000000,0.001570000000000000,0.004210000000000000,
0.004550000000000000,0.001620000000000000,0.002990000000000000,
0.002060000000000000,0.002000000000000000,0.006520000000000000,
0.001810000000000000,0.002810000000000000,0.001750000000000000,
0.001830000000000000,0.001860000000000000,0.042009999999999999,
0.002010000000000000,0.002000000000000000,0.001670000000000000,
0.002310000000000000,0.001870000000000000,0.001790000000000000,
0.002750000000000000,0.006850000000000000,0.002110000000000000,
0.004390000000000000,0.001830000000000000,0.011990000000000001,
0.010590000000000000,0.001460000000000000,0.002100000000000000,
0.002590000000000000,0.003040000000000000,0.010850000000000000,
0.001760000000000000,0.031460000000000002,0.002560000000000000,
0.002640000000000000,0.002420000000000000,0.008080000000000000,
0.001930000000000000,0.001840000000000000,0.001630000000000000,
0.002260000000000000,0.015429999999999999,0.001690000000000000,
0.001940000000000000,0.002410000000000000,0.002040000000000000,
0.019760000000000000,0.002160000000000000,0.003120000000000000,
0.001600000000000000,0.002030000000000000,0.001650000000000000,
0.001700000000000000,0.001870000000000000,0.002020000000000000,
0.004850000000000000,0.002210000000000000,0.180909999999999987,
0.002100000000000000,0.002830000000000000,0.023699999999999999,
0.001560000000000000,0.006010000000000000,0.003290000000000000,
0.001450000000000000,0.001820000000000000,0.004790000000000000,
0.002000000000000000,0.001630000000000000,0.015380000000000000,
0.002290000000000000,0.002730000000000000,0.010740000000000000,
0.001440000000000000,0.003790000000000000,0.001830000000000000,
0.002090000000000000,0.003940000000000000,0.004420000000000000,
0.025149999999999999,0.009169999999999999,0.004510000000000000,
0.017319999999999999,0.004380000000000000,0.002230000000000000,
0.002030000000000000,0.001670000000000000,0.003970000000000000,
0.001630000000000000,0.001900000000000000,0.001760000000000000,
0.001950000000000000,0.001620000000000000,0.007680000000000000,
0.003420000000000000,0.008710000000000001,0.001760000000000000,
0.011020000000000000,0.001990000000000000,0.002010000000000000,
0.001710000000000000,0.001950000000000000,0.009140000000000001,
0.001640000000000000,0.008990000000000000,0.005160000000000000,
0.026320000000000000,0.002710000000000000,0.001620000000000000,
0.002130000000000000,0.012239999999999999,0.012000000000000000,
0.001730000000000000,0.002360000000000000,0.001610000000000000,
0.001980000000000000,0.007939999999999999,0.008590000000000000,
0.004140000000000000,0.001560000000000000,0.001760000000000000,
0.003050000000000000,0.002780000000000000,0.945690000000000031,
0.006050000000000000,0.033509999999999998,0.001850000000000000,
0.009339999999999999,0.008980000000000000,0.015530000000000000,
0.002350000000000000,0.006400000000000000,0.007070000000000000,
0.003080000000000000,0.017059999999999999,0.002340000000000000,
0.002200000000000000,0.001490000000000000,0.002640000000000000,
0.001570000000000000,0.004110000000000000,0.001920000000000000,
0.026290000000000001,0.004310000000000000,0.002530000000000000,
0.003770000000000000,0.002800000000000000,0.007200000000000000,
0.001590000000000000,0.002780000000000000,0.743399999999999950,
0.059659999999999998,0.019720000000000001,0.007750000000000000,
0.004890000000000000,0.726260000000000017,0.002090000000000000,
0.047930000000000000,0.011360000000000000,0.003990000000000000,
0.003480000000000000,0.001940000000000000,0.001750000000000000,
0.001540000000000000,0.001770000000000000,0.001490000000000000,
0.004410000000000000,0.002000000000000000,0.002550000000000000,
0.004460000000000000,0.056759999999999998
)
, tolerance = 1e-8)
})
test_that('eyeData produces correct results robust_bayarri2', {
	set.seed(2019)
	eyeData <- get_eyeData()
    vy <- eyeData$vy
    mX <- eyeData$mX
    p <- ncol(mX)
    tic('eyeData produces correct results robust_bayarri2')
    result <- sampler(100000, vy, mX, prior='robust_bayarri2', modelprior='beta-binomial', modelpriorvec=c(1, p), cores=cores)
    toc()
    expect_equal(result$vinclusion_prob, 
c(
0.003630000000000000,0.005550000000000000,0.001810000000000000,
0.002090000000000000,0.003080000000000000,0.004250000000000000,
0.001800000000000000,0.004290000000000000,0.001970000000000000,
0.002430000000000000,0.063299999999999995,0.003560000000000000,
0.003430000000000000,0.002100000000000000,0.001810000000000000,
0.003470000000000000,0.001580000000000000,0.001790000000000000,
0.003130000000000000,0.001630000000000000,0.001760000000000000,
0.001930000000000000,0.002170000000000000,0.001630000000000000,
0.001640000000000000,0.003900000000000000,0.001750000000000000,
0.010680000000000000,0.001580000000000000,0.004210000000000000,
0.004550000000000000,0.001620000000000000,0.003010000000000000,
0.002060000000000000,0.002000000000000000,0.006530000000000000,
0.001820000000000000,0.002800000000000000,0.001750000000000000,
0.001830000000000000,0.001860000000000000,0.041939999999999998,
0.002010000000000000,0.002000000000000000,0.001670000000000000,
0.002310000000000000,0.001870000000000000,0.001790000000000000,
0.002750000000000000,0.006850000000000000,0.002110000000000000,
0.004390000000000000,0.001830000000000000,0.012040000000000000,
0.010580000000000001,0.001460000000000000,0.002100000000000000,
0.002600000000000000,0.003040000000000000,0.010840000000000001,
0.001750000000000000,0.031440000000000003,0.002550000000000000,
0.002640000000000000,0.002420000000000000,0.008090000000000000,
0.001930000000000000,0.001840000000000000,0.001630000000000000,
0.002260000000000000,0.015440000000000001,0.001690000000000000,
0.001940000000000000,0.002410000000000000,0.002050000000000000,
0.019750000000000000,0.002160000000000000,0.003120000000000000,
0.001620000000000000,0.002030000000000000,0.001650000000000000,
0.001700000000000000,0.001870000000000000,0.002020000000000000,
0.004840000000000000,0.002210000000000000,0.180909999999999987,
0.002100000000000000,0.002830000000000000,0.023709999999999998,
0.001560000000000000,0.005980000000000000,0.003290000000000000,
0.001450000000000000,0.001820000000000000,0.004790000000000000,
0.002000000000000000,0.001630000000000000,0.015400000000000000,
0.002290000000000000,0.002730000000000000,0.010740000000000000,
0.001440000000000000,0.003790000000000000,0.001830000000000000,
0.002080000000000000,0.003950000000000000,0.004430000000000000,
0.025040000000000000,0.009169999999999999,0.004500000000000000,
0.017319999999999999,0.004380000000000000,0.002230000000000000,
0.002030000000000000,0.001670000000000000,0.003960000000000000,
0.001630000000000000,0.001900000000000000,0.001770000000000000,
0.001950000000000000,0.001630000000000000,0.007680000000000000,
0.003420000000000000,0.008710000000000001,0.001770000000000000,
0.011010000000000001,0.002000000000000000,0.002010000000000000,
0.001710000000000000,0.001960000000000000,0.009169999999999999,
0.001630000000000000,0.008990000000000000,0.005180000000000000,
0.026320000000000000,0.002710000000000000,0.001620000000000000,
0.002130000000000000,0.012250000000000000,0.011990000000000001,
0.001730000000000000,0.002360000000000000,0.001610000000000000,
0.001960000000000000,0.007939999999999999,0.008550000000000000,
0.004140000000000000,0.001560000000000000,0.001760000000000000,
0.003040000000000000,0.002770000000000000,0.945649999999999991,
0.006070000000000000,0.033470000000000000,0.001860000000000000,
0.009320000000000000,0.008970000000000001,0.015540000000000000,
0.002340000000000000,0.006390000000000000,0.007110000000000000,
0.003080000000000000,0.017059999999999999,0.002330000000000000,
0.002200000000000000,0.001490000000000000,0.002620000000000000,
0.001570000000000000,0.004110000000000000,0.001920000000000000,
0.026280000000000001,0.004310000000000000,0.002520000000000000,
0.003770000000000000,0.002800000000000000,0.007180000000000000,
0.001600000000000000,0.002770000000000000,0.743559999999999999,
0.059670000000000001,0.019689999999999999,0.007740000000000000,
0.004900000000000000,0.726339999999999986,0.002090000000000000,
0.047960000000000003,0.011390000000000001,0.003980000000000000,
0.003480000000000000,0.001930000000000000,0.001740000000000000,
0.001540000000000000,0.001770000000000000,0.001490000000000000,
0.004390000000000000,0.002000000000000000,0.002550000000000000,
0.004480000000000000,0.056809999999999999
)
, tolerance = 1e-8)
})
test_that('eyeData produces correct results zellner_siow_gauss_laguerre', {
	set.seed(2019)
	eyeData <- get_eyeData()
    vy <- eyeData$vy
    mX <- eyeData$mX
    p <- ncol(mX)
    tic('eyeData produces correct results zellner_siow_gauss_laguerre')
    result <- sampler(100000, vy, mX, prior='zellner_siow_gauss_laguerre', modelprior='beta-binomial', modelpriorvec=c(1, p), cores=cores)
    toc()
    expect_equal(result$vinclusion_prob,
c(
0.003350000000000000,0.005180000000000000,0.001600000000000000,
0.001850000000000000,0.002800000000000000,0.003660000000000000,
0.001520000000000000,0.003890000000000000,0.001760000000000000,
0.002190000000000000,0.060069999999999998,0.003320000000000000,
0.002980000000000000,0.001970000000000000,0.001600000000000000,
0.003270000000000000,0.001410000000000000,0.001710000000000000,
0.002590000000000000,0.001480000000000000,0.001600000000000000,
0.001700000000000000,0.002030000000000000,0.001460000000000000,
0.001420000000000000,0.003670000000000000,0.001590000000000000,
0.010070000000000001,0.001290000000000000,0.003780000000000000,
0.004200000000000000,0.001410000000000000,0.002580000000000000,
0.001870000000000000,0.001830000000000000,0.006130000000000000,
0.001630000000000000,0.002660000000000000,0.001640000000000000,
0.001640000000000000,0.001670000000000000,0.040520000000000000,
0.001790000000000000,0.001680000000000000,0.001460000000000000,
0.002030000000000000,0.001670000000000000,0.001590000000000000,
0.002380000000000000,0.005990000000000000,0.001710000000000000,
0.003880000000000000,0.001650000000000000,0.010510000000000000,
0.010019999999999999,0.001290000000000000,0.001870000000000000,
0.002310000000000000,0.002710000000000000,0.010220000000000000,
0.001470000000000000,0.028989999999999998,0.002160000000000000,
0.002400000000000000,0.002110000000000000,0.007760000000000000,
0.001810000000000000,0.001650000000000000,0.001410000000000000,
0.002090000000000000,0.014579999999999999,0.001450000000000000,
0.001670000000000000,0.001960000000000000,0.001750000000000000,
0.018910000000000000,0.001880000000000000,0.002900000000000000,
0.001510000000000000,0.001870000000000000,0.001460000000000000,
0.001530000000000000,0.001670000000000000,0.001810000000000000,
0.004510000000000000,0.001960000000000000,0.175520000000000009,
0.001980000000000000,0.002540000000000000,0.021819999999999999,
0.001440000000000000,0.005360000000000000,0.002840000000000000,
0.001280000000000000,0.001740000000000000,0.004340000000000000,
0.001910000000000000,0.001460000000000000,0.014409999999999999,
0.002040000000000000,0.002330000000000000,0.009660000000000000,
0.001270000000000000,0.003350000000000000,0.001610000000000000,
0.001840000000000000,0.003430000000000000,0.003990000000000000,
0.024620000000000000,0.008540000000000001,0.003920000000000000,
0.015590000000000000,0.003960000000000000,0.002030000000000000,
0.001890000000000000,0.001560000000000000,0.003530000000000000,
0.001510000000000000,0.001720000000000000,0.001580000000000000,
0.001800000000000000,0.001460000000000000,0.007050000000000000,
0.002960000000000000,0.007770000000000000,0.001580000000000000,
0.010030000000000001,0.001790000000000000,0.001720000000000000,
0.001620000000000000,0.001740000000000000,0.008650000000000000,
0.001400000000000000,0.008290000000000000,0.004990000000000000,
0.024840000000000001,0.002510000000000000,0.001490000000000000,
0.001880000000000000,0.010489999999999999,0.011469999999999999,
0.001610000000000000,0.001910000000000000,0.001570000000000000,
0.001730000000000000,0.007120000000000000,0.007910000000000000,
0.003710000000000000,0.001410000000000000,0.001630000000000000,
0.002810000000000000,0.002540000000000000,0.950659999999999950,
0.005710000000000000,0.032280000000000003,0.001640000000000000,
0.008340000000000000,0.007860000000000001,0.014360000000000000,
0.002040000000000000,0.005800000000000000,0.006230000000000000,
0.002820000000000000,0.016480000000000002,0.002160000000000000,
0.002030000000000000,0.001360000000000000,0.002230000000000000,
0.001420000000000000,0.003860000000000000,0.001660000000000000,
0.024809999999999999,0.003730000000000000,0.002190000000000000,
0.003630000000000000,0.002480000000000000,0.006720000000000000,
0.001470000000000000,0.002450000000000000,0.757489999999999997,
0.057410000000000003,0.018710000000000001,0.007320000000000000,
0.004400000000000000,0.742229999999999945,0.001940000000000000,
0.044960000000000000,0.010149999999999999,0.003470000000000000,
0.003170000000000000,0.001770000000000000,0.001610000000000000,
0.001370000000000000,0.001600000000000000,0.001350000000000000,
0.003880000000000000,0.001790000000000000,0.002410000000000000,
0.003850000000000000,0.053920000000000003
)
, tolerance = 1e-8)
})
